<template>
<div>
  <h1>详情页面</h1>
  <p>评论内容<input type="text" v-model="form.text"></p>
  <button @click="add">确认</button>

  <h1>全部用户评论</h1>
  <ul>
    <li>用户</li>
    <li>评论内容</li>
  </ul>
  <ul v-for="i in list">
    <li>{{i.users}}</li>
    <li>{{i.text}}</li>
  </ul>

</div>
</template>

<script>
export default {
  name: "wpl",
  data(){
    return{
      form:{users:localStorage.getItem('userid'),wenzhang:this.$route.query.id},
      wenzhang_id:this.$route.query.id,
      list:[]
    }
  },
  methods:{
    add(){
      this.$axios.post('users/Pl_API/',this.form)
      .then(i=>{
        if (i.data.code == 200){
          alert("评论成功")
        }
      })
    },
    show(){
      this.$axios.get('users/Pl_API/?wenzhang_id='+this.wenzhang_id)
      .then(i=>{
        this.list = i.data.list
      })
    }
  },
  mounted() {
    this.show()
  }
}
</script>

<style scoped>

</style>
